/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package views;

import java.awt.Dimension;
import javax.swing.JInternalFrame;

/**
 *
 * @author daniel
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();
        this.setExtendedState(MAXIMIZED_BOTH);                
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        winPrincipal = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuExit = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        menuClient = new javax.swing.JMenuItem();
        menuProduct = new javax.swing.JMenuItem();
        menuUser = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        menuGenerateSale = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        txtUser2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/menu-abierto.png"))); // NOI18N
        jMenu1.setText("MENU");

        jMenuItem1.setText("HELP");
        jMenu1.add(jMenuItem1);

        menuExit.setText("EXIT");
        menuExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuExitActionPerformed(evt);
            }
        });
        jMenu1.add(menuExit);

        jMenuBar1.add(jMenu1);

        jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/apoyo.png"))); // NOI18N
        jMenu2.setText("TOOLS");

        menuClient.setText("CLIENTS");
        menuClient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuClientActionPerformed(evt);
            }
        });
        jMenu2.add(menuClient);

        menuProduct.setText("PRODUCTS");
        menuProduct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuProductActionPerformed(evt);
            }
        });
        jMenu2.add(menuProduct);

        menuUser.setText("USERS");
        menuUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuUserActionPerformed(evt);
            }
        });
        jMenu2.add(menuUser);

        jMenuBar1.add(jMenu2);

        jMenu3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/mercado.png"))); // NOI18N
        jMenu3.setText("SALES");

        menuGenerateSale.setText("GENERATE SALE");
        menuGenerateSale.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuGenerateSaleActionPerformed(evt);
            }
        });
        jMenu3.add(menuGenerateSale);

        jMenuBar1.add(jMenu3);

        jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reporte.png"))); // NOI18N
        jMenu4.setText("REPORTS");

        jMenuItem7.setText("SALE REPORTS");
        jMenu4.add(jMenuItem7);

        jMenuBar1.add(jMenu4);

        txtUser2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        txtUser2.setForeground(java.awt.Color.red);
        txtUser2.setFont(new java.awt.Font("Ubuntu", 1, 14)); // NOI18N
        jMenuBar1.add(txtUser2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(winPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(winPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_menuExitActionPerformed

    private void menuGenerateSaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuGenerateSaleActionPerformed
        SaleForm sf = new SaleForm();
        //winPrincipal.add(sf);
        //sf.setVisible(true);
        String u2 = txtUser2.getText();
        SaleForm.txtUser.setText(u2);
        
        winCentered(sf);
    }//GEN-LAST:event_menuGenerateSaleActionPerformed

    private void menuClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuClientActionPerformed
        ClientForm cf = new ClientForm();
        winCentered(cf);
    }//GEN-LAST:event_menuClientActionPerformed

    private void menuProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuProductActionPerformed
        ProductForm pf = new ProductForm();
        winCentered(pf);
    }//GEN-LAST:event_menuProductActionPerformed

    private void menuUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuUserActionPerformed
        UserForm uf = new UserForm();
        winCentered(uf);
    }//GEN-LAST:event_menuUserActionPerformed

    void winCentered(JInternalFrame frame) {
        winPrincipal.add(frame);
        Dimension dimension = winPrincipal.getSize();
        Dimension dFrame = frame.getSize();
        frame.setLocation((dimension.width - dFrame.height)/2, (dimension.height - dFrame.width)/2);
        frame.show();
    }
    
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem menuClient;
    private javax.swing.JMenuItem menuExit;
    private javax.swing.JMenuItem menuGenerateSale;
    private javax.swing.JMenuItem menuProduct;
    private javax.swing.JMenuItem menuUser;
    public static javax.swing.JMenu txtUser2;
    public static javax.swing.JDesktopPane winPrincipal;
    // End of variables declaration//GEN-END:variables
}
